package org.testis.gui.mvc.model.dynamicmap;

import org.testis.gui.mvc.model.*;
import org.testis.gui.mvc.controller.dynamicmap.WebPageParserController;
import org.testis.gui.mvc.utilities.PageParserObject;
import java.util.LinkedList;


/**
 *
 * @author Nurhat Uca, edit: Cahit Emir Erel
 */
public class WebPageParserModel extends AbstractModel
{

    private Boolean m_navigating = false;
    private Boolean m_webPageParserVisibility = false;
    private LinkedList<PageParserObject> m_parsedObjects =
        new LinkedList<PageParserObject>();
    private String m_browserType = "";
    private String m_deviceAddress = "";
    private String m_objectType = "";
    private String m_selectedFrame = "";
    private String m_selectedObjects = "";


    public String getBrowserType()
    {
        return m_browserType;
    }


    public void setBrowserType(String browserType)
    {
        if (browserType == null) {
            browserType = "";
        }
        String oldBrowserType = m_browserType;
        m_browserType = browserType;
        firePropertyChange(WebPageParserController.CHANGE_BROWSER_TYPE,
                           oldBrowserType,
                           browserType);
    }


    public String getDeviceAddress()
    {
        return m_deviceAddress;
    }


    public void setDeviceAddress(String deviceAddress)
    {
        if (deviceAddress == null) {
            deviceAddress = "";
        }
        String oldDeviceAddress = m_deviceAddress;
        m_deviceAddress = deviceAddress;
        firePropertyChange(WebPageParserController.CHANGE_DECIVE_ADDRESS,
                           oldDeviceAddress,
                           deviceAddress);
    }


    public String getObjectType()
    {
        return m_objectType;
    }


    public void setObjectType(String objectType)
    {
        if (objectType == null) {
            objectType = "";
        }
        String oldObjectType = m_objectType;
        m_objectType = objectType;
        firePropertyChange(WebPageParserController.CHANGE_OBJECT_TYPE,
                           oldObjectType,
                           objectType);
    }


    public String getSelectedFrame()
    {
        return m_selectedFrame;
    }


    public void setSelectedFrame(String selectedFrame)
    {
        if (selectedFrame == null) {
            selectedFrame = "";
        }
        String oldSelectedFrame = m_selectedFrame;
        m_selectedFrame = selectedFrame;
        firePropertyChange(WebPageParserController.CHANGE_SELECTED_FRAME,
                           oldSelectedFrame,
                           selectedFrame);
    }


    public void setWebPageParserVisibility(Boolean webPageParserVisibility)
    {
        if (webPageParserVisibility == null) {
            return;
        }
        Boolean oldWebPageParserVisibility = m_webPageParserVisibility;
        m_webPageParserVisibility = webPageParserVisibility;
        firePropertyChange(WebPageParserController.SHOW_WEB_PAGE_PARSER,
                           oldWebPageParserVisibility,
                           webPageParserVisibility);
    }


    public Boolean getWebPageParserVisibility()
    {
        return m_webPageParserVisibility;
    }


    public void setLastError(String lastError)
    {
        if (lastError == null) {
            lastError =
                "null String given to WebPageParselModel.java --- setLastError method";
        }
        firePropertyChange(WebPageParserController.SHOW_ERROR,
                           "",
                           lastError);
    }


    public boolean getNavigating()
    {
        return m_navigating;
    }


    public void setNavigating(Boolean navigating)
    {
        if (navigating == null) {
            return;
        }
        Boolean oldNavigating = m_navigating;
        m_navigating = navigating;
        firePropertyChange(WebPageParserController.CHANGE_NAVIGATING,
                           oldNavigating,
                           navigating);
    }


    public String getSelectedObjects()
    {
        return m_selectedObjects;
    }


    public void setSelectedObjects(String selectedObjects)
    {
        if (selectedObjects == null) {
            selectedObjects = "";
        }
        String oldSelectedObjects = m_selectedObjects;
        m_selectedObjects = selectedObjects;
        firePropertyChange(WebPageParserController.CHANGE_SELECTED_OBJECTS,
                           oldSelectedObjects,
                           selectedObjects);
    }


    public LinkedList<PageParserObject> getParsedObjects()
    {
        return m_parsedObjects;
    }


    public void setParsedObjects(LinkedList<PageParserObject> parsedObjects)
    {
        if (parsedObjects == null) {
            parsedObjects = new LinkedList<PageParserObject>();
        }
        LinkedList<PageParserObject> oldParsedObjects = m_parsedObjects;
        m_parsedObjects = parsedObjects;
        firePropertyChange(WebPageParserController.PARSE_SELECTED_OBJECTS,
                           oldParsedObjects,
                           parsedObjects);
    }
}
